const http = uni.$u.http

// 施工班
//根据身份证号获取施工班班长所负责的各过程状态的施工单数量
export function getCFStateNum() {
	const userInfo = uni.getStorageSync('userInfo');
	const {
		code = '',
		orgId
	} = userInfo
	return http.get('/app/cfStateNum', {
		params: {
			code,
			agentId: orgId,
		}
	});
}

//施工班组人员
export function getComponentInformation() {
	return http.get('/cfc/getComponentInformation');
}

// 施工班班长待开工施工单列表
export function getLeaderNoStartProject(params) {
	const userInfo = uni.getStorageSync('userInfo');
	const {
		code = '',
		orgId
	} = userInfo
	return http.get('/cfc/getLeaderNoStartProject', {
		params: {
			code,
			agentId: orgId,
			...params
		}
	});
}

// 施工班班长进行中施工单列表
export function getLeaderProcessingProject(params) {
	const userInfo = uni.getStorageSync('userInfo');
	const {
		code = '',
		orgId
	} = userInfo
	return http.get('/cfc/getLeaderProcessingProject', {
		params: {
			code,
			agentId: orgId,
			projectState: 5,
			...params
		}
	});
}

// 施工班班长待整改施工单列表
export function getLeaderNoStartRectify(params) {
	const userInfo = uni.getStorageSync('userInfo');
	const {
		code = '',
		orgId
	} = userInfo
	return http.get('/cfc/getLeaderNoStartRectify', {
		params: {
			code,
			agentId: orgId,
			...params
		}
	});
}

// 施工班班长整改待审批施工单列表
export function getLeaderApplyRectify(params) {
	const userInfo = uni.getStorageSync('userInfo');
	const {
		code = '',
		orgId
	} = userInfo
	return http.get('/cfc/getLeaderApplyRectify', {
		params: {
			code,
			agentId: orgId,
			...params
		}
	});
}

// 施工班班长已完工施工单列表
export function getLeaderFinishedProject(params) {
	const userInfo = uni.getStorageSync('userInfo');
	const {
		code = '',
		orgId
	} = userInfo
	return http.get('/cfc/getLeaderFinishedProject', {
		params: {
			code,
			agentId: orgId,
			...params
		}
	});
}

// 施工班班长已完工施工单列表
export function getCfDetail(params) {
	return http.get('/cfc/getCfDetail', {
		params
	});
}

export function addStartApplyCfRecord(data) {
	return http.post('/cfc/addStartApplyCfRecord', data);
}

export function updateStartApplyCfStatus(params) {
	return http.get('/cfc/updateStartApplyCfStatus', {
		params
	});
}

export function getAgentBuildMembers(params) {
	return http.get('/cfc/getAgentBuildMembers', {
		params
	});
}

export function updateCfFinishedStatus(data) {
	return http.post('/cfc/updateCfFinishedStatus', data);
}

export function updateCfProcessingBuild(data) {
	return http.post('/cfc/updateCfProcessingBuild', data);
}

export function updateCfRejectRecord(data) {
	return http.post('/cfc/updateCfRejectRecord', data);
}

//新增交底表接口
export function getSafeTechBaseRecordFile(params) {
	return http.get('/cfc/getSafeTechBaseRecordFile', {
		params,
		custom: {
			showToast: false
		}
	});
}

export function getSafeTechBaseRecord(data) {
	return http.post('/cfc/getSafeTechBaseRecord', data, {
		custom: {
			showToast: false
		}
	});
}
//保存安全技术交底表 
export function getConstructionDisclosure(params) {
	return http.get('/cfc/getConstructionDisclosure', {
		params
	});
}
//获取安全技术交底表 
export function updateConstructionDisclosure(data) {
	return http.post('/cfc/updateConstructionDisclosure', data, {
		custom: {
			showToast: false
		}
	});
}

export function getInstallationTestCheckRecord(data) {
	return http.post('/cfc/getInstallationTestCheckRecord', data);
}

export function getUserLightSysSelfCheck(data) {
	return http.post('/cfc/getUserLightSysSelfCheck', data);
}
//查询
export function getInstallationTest(params) {
	return http.get(`/cfc/getInstallationTest`, {
		params
	});
}
//更改
export function updateInstallationTest(data) {
	return http.post('/cfc/updateInstallationTest', data);
}
// 代理商
export function getAgentStateNum() {
	const userInfo = uni.getStorageSync('userInfo');
	const {
		orgId,
		userRoleId,
	} = userInfo
	return http.get('/agent/projectStateNum', {
		params: {
			agentId: orgId,
			userRole: userRoleId
		}
	});
}

export function getGoingRectifyCf(params) {
	const userInfo = uni.getStorageSync('userInfo');
	const {
		orgId
	} = userInfo
	return http.get('/agent/goingRectifyCf', {
		params: {
			agentId: orgId,
			...params,
			curUid: userInfo.userId,
		}
	});
}

export function getRectifyCheckCf(params) {
	const userInfo = uni.getStorageSync('userInfo');
	const {
		orgId
	} = userInfo
	return http.get('/agent/rectifyCheckCf', {
		params: {
			agentId: orgId,
			...params,
			curUid: userInfo.userId,
		}
	});
}

export function getRectifyFinishedCf(params) {
	const userInfo = uni.getStorageSync('userInfo');
	const {
		orgId
	} = userInfo
	return http.get('/agent/rectifyFinishedCf', {
		params: {
			agentId: orgId,
			...params
		},
		curUid: userInfo.userId,
	});
}

export function getApplyCheckCf(params) {
	const userInfo = uni.getStorageSync('userInfo');
	const {
		orgId
	} = userInfo
	return http.get('/agent/applyCheckCf', {
		params: {
			agentId: orgId,
			...params
		}
	});
}

export function getProcessingCf(params) {
	const userInfo = uni.getStorageSync('userInfo');
	const {
		orgId
	} = userInfo
	return http.get('/agent/processingCf', {
		params: {
			agentId: orgId,
			projectState: 5,
			...params
		}
	});
}

export function getFinishedCf(params) {
	const userInfo = uni.getStorageSync('userInfo');
	const {
		orgId
	} = userInfo
	return http.get('/agent/finishedCf', {
		params: {
			agentId: orgId,
			...params
		}
	});
}

// 开工/复工申请审批-通过
export function updateProcessApply(params) {
	return http.get('/agent/updateProcessApply', {
		params
	});
}

// 开工/复工申请审批-驳回
export function addCfRejectRecord(data) {
	return http.post('/agent/addCfRejectRecord', data);
}

// 整改申请审批-通过
export function updateRectifyApply(params) {
	return http.get('/agent/updateRectifyApply', {
		params
	});
}

export function rejectRectifyApply(data) {
	return http.post('/agent/rejectRectifyApply', data);
}

// 完工/部分完工状态更改(需要同步信息给订单系统那边)
export function updateFinishState(params) {
	return http.get('/agent/updateFinishState', {
		params
	});
}

// 施工单转办-重新指定施工班班长
export function updateCfLeader(params) {
	return http.get('/agent/updateCfLeader', {
		params
	});
}

// 撤销施工单
export function revokeCf(data) {
	return http.post('/cfc/revokeCf', data);
}

// 获取二级安全员-配置机构及子机构
export function getSaferOrgs(userId) {
	if (!userId) {
		userId = 0;
	}
	return http.get('/safer/getSaferOrgs', {
		params: {
			userId
		}
	});
}

// 获取1/2级安全员首页各状态工单数量
export function getSaferStateNum() {
	const userInfo = uni.getStorageSync('userInfo');
	const safeOrg = uni.getStorageSync('safeOrg');
	let params = {};
	params.orgId = 0;
	params.userId = userInfo.userId;
	return http.get('/safer/getSaferStateNum', {
		params
	});
}

// 一/二级安全员: 整改管理施工单列表
export function getSaferRecitfyCf(params) {
	const userInfo = uni.getStorageSync('userInfo');
	const safeOrg = uni.getStorageSync('safeOrg');
	let data = {};
	data.orgId = 0;
	data.userId = userInfo.userId;
	data.curUid = userInfo.userId;
	return http.get('/safer/recitfyCf', {
		params: {
			...params,
			...data
		}
	});
}

// 一/二级安全员: 进行中施工单列表
export function getSaferProcessingCf(params) {
	const userInfo = uni.getStorageSync('userInfo');
	let data = {};
	data.orgId = 0;
	data.userId = userInfo.userId;
	return http.get('/safer/processingCf', {
		params: {
			...params,
			...data
		}
	});
}

// 一/二级安全员: 已完工施工单列表
export function getSaferFinishedCf(params) {
	const userInfo = uni.getStorageSync('userInfo');
	let data = {};
	data.orgId = 0;
	data.userId = userInfo.userId;
	return http.get('/safer/finishedCf', {
		params: {
			...params,
			...data
		}
	});
}

export function getOffice() {
	return http.get('/pc/getAllBshOrgs');
}

export function getProcessTask(params) {
	return http.get('/pc/cf/processingCfList', {
		params
	});
}
//修改
export function updateCableSteelSynTemplate(data) {
	return http.post('/stationGuest/updateSteelSynTemplate', {
		...data
	});
}
//查询
export function getSealedColorSteel(params) {
	return http.get('/stationGuest/getSealedColorSteel', {
		params
	})
}

export function getAlaramList(params) {
	const userInfo = uni.getStorageSync('userInfo');
	let data = {};
	data.orgId = userInfo.orgId;
	if (['FristClassSafer', 'SecondClassSafer', 'Admin'].includes(userInfo.userRole || '')) {
		data.orgId = 0;
	}
	data.userId = userInfo.userId;
	if (['ConstructionLeader'].includes(userInfo.userRole)) {
		data.leaderIdNumber = userInfo.code;
		data.role = userInfo.userRoleId;
	}
	return http.get('/pc/cf/getAlaramList', {
		params: {
			...params,
			...data,
		}
	});
}
//获取订单是否已审核
export function getByCf(data) {
	return http.get('/reportCenter/auditLog/getByCf', {
		params: {
			...data
		}
	});
}
//抽审施工单
export function auditConstructionForm(data) {
	return http.post('/reportCenter/auditConstructionForm', data);
}
//设备离线提交故障单
export function addFault(params) {
	return http.post('/cfc/device/video/breakdown/submit', {
		...params
	});
}
//检测设备离线是否故障
export function isFault(params) {
	return http.post('/cfc/device/video/breakdown/query/status', {
		...params
	});
}
//APP查询施工班组长最新的视频设备id
export function getDeviceId(params) {
	return http.post('/cfc/device/video/leader/info', {
		...params
	});
}
